"use strict";

const BaseModel = require("../basics/mysql/mapper");
const Constant = require("../basics/constant");
class HomeModel extends BaseModel {
  constructor(cloud) {
    super(cloud, "dicts");
  }

  /**
   * 获取实例
   * @param {*} cloud 
   */
  static getInstant(cloud) {
    return new HomeModel(cloud);
  }


  /**
   * 查询单条
   * @param {*} code 
   */
  async selectOneByCode(code) {
    const ex = this.createExample();
    ex.criteria.andEqual("code", code);
    return await this.selectOneByExample(ex);
  }

  /**
   * 查询单条
   */
  async selectTaskList() {
    const ex = this.createExample();
    ex.criteria.andEqual("code", Constant.DICS.task_list);
    const data = await this.selectOneByExample(ex);
    if (!data || !data.details) {
      return [];
    }
    return JSON.parse(data.details);
  }

}

module.exports = HomeModel;